From 18b8dd067a7ed14272043da5cc9ec0ca3e6997db Mon Sep 17 00:00:00 2001 From: Christian Limpach Date: Tue, 24 Apr 2007 17:02:09 +0100 Subject: [PATCH] [qemu-dm] Add bounds checks to block device reads/writes. Signed-off-by: Christian Limpach --- tools/ioemu/block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/ioemu/block.c b/tools/ioemu/block.c index 00444abb19..34757f4557 100644 --- a/tools/ioemu/block.c +++ b/tools/ioemu/block.c @@ -420,6 +420,8 @@ int bdrv_read(BlockDriverState *bs, int64_t sector_num, if (!bs->inserted) return -1; + if (sector_num < 0) + return -1; while (nb_sectors > 0) { if (sector_num == 0 && bs->boot_sector_enabled) { @@ -458,6 +460,8 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num, return -1; if (bs->read_only) return -1; + if (sector_num < 0) + return -1; if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { memcpy(bs->boot_sector_data, buf, 512); } -- 2.30.2